﻿using PureMVC.Interfaces;
using SuperMap.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Rail.Start.Viewer
{
    class OpenEngineeringFormMediator : PureMVC.Patterns.Mediator, IMediator
    {
        OpenEngineeringForm m_OpenEngineeringForm;
        public OpenEngineeringFormMediator(OpenEngineeringForm openEngineering)
               : base(NAME, openEngineering)
        {
            m_OpenEngineeringForm = openEngineering;
            InitialEvent();
        }
        private void InitialEvent()
        {
            m_OpenEngineeringForm.SimpleButton.MouseClick += OpenEvent;
        }
        private void OpenEvent(object sender, EventArgs e)
        {
            object workspace_name;
            m_OpenEngineeringForm.m_Pairs.TryGetValue(m_OpenEngineeringForm.ComboBoxEngineer.Text.Trim(), out workspace_name);
            string m_path = System.IO.Path.Combine(Commons.Paths.ApplicationWorkspaceDir, workspace_name + "." + "SMWU");
            FormMain.formMain.m_sampleRun.Open(new WorkspaceConnectionInfo(m_path));
            m_OpenEngineeringForm.Close();

        }
    }
}
